const express = require("express")
const bodyParser = require("body-parser")
const path = require("path")
const app = express()
app.use(express.static(path.join(__dirname, "public")))
//请求体的解码
app.use(bodyParser.urlencoded())
app.use(bodyParser.json())

app.post("/post1", (req, res) => {
    res.send("hello ajax post")
})

app.post("/post2", (req, res) => {
    // post请求的参数放在那里 req.body  对象
    console.log(req.body);
    res.send(`您已经注册成功，您的账号是${req.body.username},您的密码是${req.body.password}`)
})

app.post("/post3", (req, res) => {
    // post请求的参数放在这里 req.body  对象
    console.log(req.body);
    res.send(`您已经注册成功，您的账号是${req.body.username},您的密码是${req.body.password}`)
})

let server = app.listen(3000, () =>{
    console.log("服务已经运行在3000端口");
})